package com.enation.app.shop.front.api.random.serviceImpl;

import com.enation.app.shop.front.api.random.IMobileRandomManager;
import com.enation.app.shop.front.api.random.entity.MoblieRandom;
import com.enation.framework.database.IDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("mobileRandomService")
public class MobileRandomManager implements IMobileRandomManager {
    @Autowired
    private IDaoSupport daoSupport;
    @Override
    public MoblieRandom getById(int id) {
        String sql="select * from rbt_random where id=?";
        List<MoblieRandom> creditAccountList1=daoSupport.queryForList(sql,MoblieRandom.class,id);
        if (creditAccountList1.size()==0){
            return null;
        }else {
            return  creditAccountList1.get(0);
        }
    }

    @Override
    public MoblieRandom getByMobileRandom(String mobilerandom,Integer userid,String mobile) {
        String sql="select * from rbt_random where random=? and userid=? and mobile=?";
        List<MoblieRandom> creditAccountList1=daoSupport.queryForList(sql,MoblieRandom.class,mobilerandom,userid,mobile);
        if (creditAccountList1.size()==0){
            return null;
        }else {
            return  creditAccountList1.get(0);
        }
    }

    @Override
    public int creatMobileRandom(MoblieRandom moblieRandom) {
        this.daoSupport.insert("rbt_random",moblieRandom);
        int i=9;
        return 1;
    }
}
